package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by shaunaks on 28/02/14.
 */
public class UserAccount
{
    private String libraryNumber;
    private String loginPassword;
    private String userName;
    private String userEmail;
    private String userPhoneNumber;
    private ArrayList<Book> listOfBorrowedBooks;
    private ArrayList<Movie> listOfBorrowedMovies;

    public UserAccount(String libraryNumber, String loginPassword, String userName, String userEmail, String userPhoneNumber) {
        this.libraryNumber=libraryNumber;
        this.loginPassword=loginPassword;
        this.userName = userName;
        this.userEmail = userEmail;
        this.userPhoneNumber = userPhoneNumber;
        listOfBorrowedBooks=new ArrayList<Book>();
        listOfBorrowedMovies=new ArrayList<Movie>();
    }

    public ArrayList<Book> getListOfBorrowedBooks() {

        return listOfBorrowedBooks;
    }

    public ArrayList<Movie> getListOfBorrowedMovies() {
        return listOfBorrowedMovies;
    }

    public String getUserName() {return userName;}

    public String getUserEmail() {return userEmail;}

    public String getUserPhoneNumber() {return userPhoneNumber;}

    public String getLibraryNumber() {return libraryNumber;}

    public String getLoginPassword() {return loginPassword;}


    public boolean addBookOrMovieToRespectiveList(Object object)
    {
        if(object instanceof Book)
        {
            Book book=(Book)object;
            listOfBorrowedBooks.add(book);
            return true;
        }
        else if(object instanceof Movie)
        {
            Movie movie=(Movie)object;
            listOfBorrowedMovies.add(movie);
            return true;
        }
        return false;
    }


    @Override
    public String toString()
    {
        return ("Name:"+this.getUserName()+"\tEmail:"+this.getUserEmail()+"\tPhone Number:"+this.getUserPhoneNumber());

    }


    public boolean removeBookOrMovieFromRespectiveList(Object object)
    {
        if(object instanceof Book)
        {
            Book book=(Book)object;
            listOfBorrowedBooks.remove(book);
            return true;
        }
        else if(object instanceof Movie)
        {
            Movie movie=(Movie)object;
            listOfBorrowedMovies.remove(movie);
            return true;
        }
        return false;
    }
}
